
set(_install_targets)

aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} _SOURCES )
# 默认创建静态库，由 BUILD_SHARED_LIBS 决定是否创建动态库
add_library(libexample ${_SOURCES})

target_include_directories (libexample
	INTERFACE "$<INSTALL_INTERFACE:include>"  "$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}>"
	PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}>"
)
set(_public_headers)
list(APPEND _public_headers libexample.h )

set_target_properties (libexample  PROPERTIES 
	PUBLIC_HEADER "${_public_headers}"
	DEBUG_POSTFIX _d
	INTERFACE_POSITION_INDEPENDENT_CODE ON
)
list(APPEND _install_targets libexample)

################安装脚本#################
if(WIN32 AND NOT CYGWIN)
set (CONFIG_INSTALL_DIR  cmake)
else()
set (CONFIG_INSTALL_DIR  ${LIBRARY_INSTALL_DIR}/cmake/libexample)
endif()
include (CMakePackageConfigHelpers)
set (libexample_DEPENDENCY "")
configure_package_config_file (${PROJECT_SOURCE_DIR}/cmake/config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/libexample-config.cmake
INSTALL_DESTINATION ${CONFIG_INSTALL_DIR}
NO_CHECK_REQUIRED_COMPONENTS_MACRO)
write_basic_package_version_file (libexample-config-version.cmake VERSION
${PROJECT_VERSION} COMPATIBILITY SameMajorVersion)
install (FILES
	${CMAKE_CURRENT_BINARY_DIR}/libexample-config.cmake
	${CMAKE_CURRENT_BINARY_DIR}/libexample-config-version.cmake
	DESTINATION ${CONFIG_INSTALL_DIR}
	)
install(TARGETS ${_exe_targets} ${_install_targets} EXPORT libexample-targets
	RUNTIME DESTINATION ${RUNTIME_INSTALL_DIR}
	LIBRARY DESTINATION ${LIBRARY_INSTALL_DIR}
	ARCHIVE DESTINATION ${LIBRARY_INSTALL_DIR}
	PUBLIC_HEADER DESTINATION ${INCLUDE_INSTALL_DIR}/libexample
	)

# export library information for CMake projects
install(EXPORT libexample-targets DESTINATION "${CONFIG_INSTALL_DIR}")

unset(_SOURCES)
unset(_public_headers)
